import { createRouter, createWebHistory } from 'vue-router'

const routes = [
  {
    path: '/',
    name: 'Camera',
    component: () => import('../views/Camera.vue'),
    props: true
  },
  {
    path: '/result',
    name: 'Result',
    component: () => import('../views/Result.vue'),
    props: true
  }
]

const router = createRouter({
  history: createWebHistory(),
  routes
})

router.beforeEach((to, from, next) => {
  if (to.matched.length === 0) {
    next('/')
    return
  }
  next()
})

export default router